package openai

import (
	"github.com/gofiber/fiber/v2"
	"shyxy-net/gateway/http/services/model"
	fiberPkg "shyxy-net/pkg/fiber"
)

func ListModelsEndpoint(modelService *model.Service) func(ctx *fiber.Ctx) error {
	return func(ctx *fiber.Ctx) error {
		models, err := modelService.ListModels()
		if err != nil {
			return ctx.Status(fiber.StatusInternalServerError).JSON(fiberPkg.FailedWithErrCode(fiberPkg.NetworkError))
		}
		return ctx.Status(fiber.StatusOK).JSON(fiberPkg.Succeed(fiber.Map{
			"models": models,
		}))
	}
}
